public class Test {
	static int[] a = new int[9];
	static int[] mark = new int[9];

	public static void main(final String[] args) {
		final long s_time = System.currentTimeMillis();
		dfs(0);
		System.out.println(System.currentTimeMillis() - s_time);
	}

	private static void dfs(final int pos) {
		// 剪枝
		if (pos == 3) {
			final int n1 = get_num_n(1);
			if (n1 > 329) {
				return;
			}
		}
		if (pos == 6) {
			final int n1 = get_num_n(1);
			final int n2 = get_num_n(2);
			if ((n2 != (n1 * 2)) || (n2 < 246) || (n2 > 658)) {
				return;
			}
		}
		// 剪枝end
		if (pos == 9) {
			final int x = get_num_n(1);
			final int y = get_num_n(2);
			final int z = get_num_n(3);
			if (((x * 2) == y) && ((x * 3) == z)) {
				System.out.println(x);
				System.out.println(y);
				System.out.println(z);
				System.out.println("///////////////////////");
			}
			return;
		}
		for (int i = 0; i < 9; i++) {
			if (mark[i] == 1) {
				continue;
			}
			a[pos] = i + 1;
			mark[i] = 1;
			dfs(pos + 1);
			mark[i] = 0;// 还原
		}
	}

	static int get_num_n(final int n) {
		final int x = (n - 1) * 3;
		return (a[x] * 100) + (a[x + 1] * 10) + a[x + 2];
	}
}
